struct MyStruct {
    public static var xyz = "hi";

    var a: Int = 1;
    var b: CString = "hello";
    var c = 5;
    var d: Bool = undefined;
    var e: Ptr[Float];
}

struct MyStruct2 {
    var a: MyStruct;
}

struct MyStruct3 {
    var a: MyStruct2;
    var b: Ptr[MyStruct];
}

function main() {
    var f = 5_f32;
    var a = struct MyStruct {
        c: 6,
        d: true,
        e: f,
    };
    // autorefderef of struct pointer field
    var g: Float = a.e;
    printf("%.1f\n", g);

    printf("%s\n", MyStruct.xyz);
    printf("%s\n", a.b);

    var b: Ptr[MyStruct] = &a;
    var y = b.a;

    var s2 = struct MyStruct2 {a};
    var s3 = struct MyStruct3 {a: s2, b: a};

    puts("MyStruct fields:");
    for field in MyStruct.fields {
        printf("- ");
        puts(field);
    }

    // reassign with default values
    printf("%i %s\n", a.c, if a.d then "true" else "false");
    a = struct MyStruct {d: false};
    printf("%i %s\n", a.c, if a.d then "true" else "false");
}
